package config.java;

import org.apache.commons.logging.Log;
/**
 * 日志输出<br>
 * 如果定义了Log则会通过log来输出，否则直接输出到控制台
 * @author liao
 *
 */
public class ConfigLog {

	private static Log logger = null;
	
	public static void setLog(Log log){
		logger = log;
	}
	
	public static void debugLog(String msg){
		if(logger != null){
			logger.debug(msg);
		}else{
			System.out.println(msg);
		}
	}
	
	public static void errorLog(String msg){
		if(logger != null){
			logger.error(msg);
		}else{
			System.out.println(msg);
		}
	}
	
	public static void errorLog(Exception ex){
		if(logger != null){
			logger.error(ex.toString());
		}else{
			ex.printStackTrace();
		}
	}
}
